<?php


namespace app\api\model;

use app\model\CouponOrder as BaseCouponOrder;
use app\model\MovieOrder;

class CouponOrder extends BaseCouponOrder
{

    const IS_SHOW_CODE = 1;
    const IS_HIDE_CODE = 2;

    /**
     * @param $value
     * @param $model
     * @return false|int
     */
    public function getRealTicketImageAttr($value, $model)
    {
        $ext_data = $model['ext_data'];
        $is_show_code = self::IS_HIDE_CODE;
        $arr = [];
        //如果二维码为空
        foreach ($ext_data['ticket_code'] as $code) {
            $arr[$code] = env('app.api_url').'/qr?code=' . $code.'&isShowCode='.$is_show_code;
        }
        return $arr;
    }

    /**
     * @param $value
     * @param $model
     * @return false|int
     */
    public function getPlanTypeAttr($value, $model)
    {
        $supplier_order_sn = $model['supplier_order_sn'];
        return MovieOrder::query()->where('order_id', $supplier_order_sn)->value('plan_type');
    }
}